class Solution:
    def superPow(self, a: int, b: list[int]) -> int:
        #分而治之
        #递归基：a^0 = 1
        if not b: return 1
        #递归：a^[b1,b2,...bn] = a^[b1,b2,...b_(n-1)]^10 * a^bn
        return (self.superPow(a,b[:-1])%1337)**10 * (a%1337)**b[-1] %1337
